using System;

namespace ZyGame.Event
{
    public abstract class EventArgsData<T> : IDisposable where T : EventArgsData<T>
    {
        public string name { get; protected set; }
        public object value { get; protected set; }

        public virtual void Dispose()
        {
            name = String.Empty;
            value = null;
            GC.SuppressFinalize(this);
        }

        public virtual void Initialize(params object[] dataList)
        {
        }

        public static T Create(params object[] dataList)
        {
            T instance = Activator.CreateInstance<T>();
            if (dataList is not null && dataList.Length > 0)
            {
                instance.Initialize(dataList);
            }

            return instance;
        }
    }
}